<template>
	<div>
		<header-footer :commonData="{$parent:$parent,indexLogo:1}">
			<div class="newsCenter" v-cloak>
				<div class="crumb width1200">
					<ul>
						<li class="f_left">当前位置：</li>
						<li class="f_left">
							<router-link to="/home">首页></router-link>
						</li>
						<li class="f_left">新闻中心</li>
					</ul>
				</div>
				<div class="news_content">
					<div class="news_tabs f_left text_center">
						<ul>
							<li v-for="(tab,index) in tabs" :key="index">
								<router-link :newsType="tab.newsType" :to="tab.aHref" :class="{news_tabs_a_active:tab.newsType==type}">{{tab.title}}</router-link>
							</li>
						</ul>
					</div>
					<div class="news_tabs_content f_left">
						<h3 class="text_center">{{title}}</h3>
						<div class="news_tab_table_box">
							<table class="news_tab_table" width="100%">
								<tbody>
									<tr v-for="(item,index) in newsLst" :key="index">
										<td class="news_tab_table_tr1 text_left">
											<router-link class="color333" target="_blank" :to="String.Format('/news/news_info/{0}',item.id)" :title="item.title">{{item.title}}</router-link>
										</td>
										<td class="text_right">
											{{new Date(item.updateTime).Format("yyyy-MM-dd")}}
										</td>
									</tr>
								</tbody>
							</table>
						</div>
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                            :current-page.sync="pageNo" :page-sizes="[5, 10]"
                            layout="total, sizes, prev, pager, next, jumper" :total="total">
                        </el-pagination>
					</div>
					<div class="clear"></div>
				</div>
			</div>
		</header-footer>
	</div>
</template>

<script>
	import headerFooter from '../../components/cont_education/header_and_footer.vue'
	export default {
		name: 'news_center',
		data() {
			return {
				type: 1,
				tabs: [{
						'title': '行业头条',
						'newsType': 1,
						'aHref': '/news/news_1'
					},
					{
						'title': '通知公告',
						'newsType': 2,
						'aHref': '/news/news_2'
					},
				],
				title: "",
				total: 100,
                    limit: 10,
                    pageNo: 1,
				newsLst: [],
			}
		},
		mounted: function() {
			this.init();
		},
		methods: {
			init: function() {
				this.type = parseInt(this.$route.params.type);
				this.title = this.tabs[this.type - 1].title;
				this.getList();
			},
			getList: function() {
				// this.currentPage = pageNo;
				var that = this;
				this.common.post(this.api.getNewsList, {
					newsType: this.type,
					minId: this.pageNo,
					pageSize: this.limit,
				}, function(res) {
                    that.total = parseInt(res.total);
                    that.newsLst = res.resultMap;
					// that.newsLst = res.resultMap;
					// that.total=res.total;
				});
			},
            //分页当前页点击
            handleCurrentChange: function(val) {
                this.pageNo = val;
                this.getList();
            },
            //分页选择
            handleSizeChange: function(val) {
                this.pageNo = 1;
                this.limit = val;
                this.getList();
            },
		},
		components: {
			headerFooter
		},
		watch: {
			'$route': function(to, from) {
				this.init();
			}
		}
	}
</script>

<style>
</style>
